package org.grow.swimming.exception;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: xwg
 * @CreateDate: 2022/5/7
 */

@RestControllerAdvice
public class ExceptionBridge {

    @ExceptionHandler(NoticeException.class)
    public ResponseEntity<String> handleNotice(NoticeException e) {
        return new ResponseEntity<String>(e.getMessage(), null, e.getCode());
    }

    @ExceptionHandler(StateException.class)
    public ResponseEntity<String> handleState(StateException e) {
        return new ResponseEntity<String>(e.getMessage(), null, e.getCode());
    }
}
